package cn.ctodb.mall.goods.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A GoodAttr.
 */
@Entity
@Table(name = "good_attr")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "goodattr")
public class GoodAttr implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Lob
    @Column(name = "attr_value")
    private String attrValue;

    @Column(name = "attr_pric")
    private String attrPric;

    @ManyToOne
    private Goods goods;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAttrValue() {
        return attrValue;
    }

    public GoodAttr attrValue(String attrValue) {
        this.attrValue = attrValue;
        return this;
    }

    public void setAttrValue(String attrValue) {
        this.attrValue = attrValue;
    }

    public String getAttrPric() {
        return attrPric;
    }

    public GoodAttr attrPric(String attrPric) {
        this.attrPric = attrPric;
        return this;
    }

    public void setAttrPric(String attrPric) {
        this.attrPric = attrPric;
    }

    public Goods getGoods() {
        return goods;
    }

    public GoodAttr goods(Goods goods) {
        this.goods = goods;
        return this;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GoodAttr goodAttr = (GoodAttr) o;
        if (goodAttr.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, goodAttr.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "GoodAttr{" +
            "id=" + id +
            ", attrValue='" + attrValue + "'" +
            ", attrPric='" + attrPric + "'" +
            '}';
    }
}
